<template>
    <div class="need-login-window">

    </div>
</template>

<script>
import { Dialog } from 'vant'
import { delLoginUserInfo, isLoginChose } from '_projectFn/login'
import { toLoginPage } from '_projectFn/url'

export default {
    name: 'NeedLoginWindow',
    props: {
        isShow: {
            type: Boolean,
            default: false,
        },
        btnText: {
            type: String,
            default: '微信登录'
        },
        btnColor: {
            type: String,
            default: '#0077bf'
        },
        title: {
            type: String,
            default: ''
        },
        message: {
            type: String,
            default: '请微信登录后进行原因分析!'
        },
        closeOnClickOverlay: {
            type: Boolean,
            default: true,
        },
        className: {
            type: String,
            default: 'no-login'
        },
        width: {
            default: 280,
        }
    },
    watch: {
        isShow() {
            const that = this
            if (this.isShow) {
                Dialog.alert({
                    message: this.message,
                    title: this.title,
                    confirmButtonText: this.btnText,
                    confirmButtonColor: this.btnColor,
                    closeOnClickOverlay: this.closeOnClickOverlay,
                    className: this.className,
                    width: this.width,
                    beforeClose(action, done) {
                        // console.log('action', action)
                        that.$emit('closeNeedLooginWindow')
                        done()
                    }
                }).then(() => {
                    // console.log('点击微信登录')
                    delLoginUserInfo()
                    // isLoginChose()
                    toLoginPage({})
                    // Dialog.close()
                })
            } else {
                Dialog.close()
            }
        }
    },
    deactivated() {
        Dialog.close()
    },
}
</script>

<style lang="scss">
.no-login {
    width: 250px;
    .van-button__text {
        font-size: 14px;
    }
}
</style>